package com.ihemou.system.service.impl;

import com.ihemou.system.domain.SysUserSocialUser;
import com.ihemou.system.mapper.SysUserSocialUserMapper;
import com.ihemou.system.service.ISysUserSocialUserService;
import org.springframework.beans.factory.annotation.Autowired;
import org.springframework.stereotype.Service;
import org.springframework.transaction.annotation.Propagation;
import org.springframework.transaction.annotation.Transactional;

import java.util.Arrays;
import java.util.List;

/**
 * All rights Reserved, Designed By saperliu
 * Copyright:    Copyright(C) 2021-2021
 * 关联系统账号Service业务层处理
 *
 * @author saperliu
 * @date 2021年09月02日
 */
@Service
public class SysUserSocialUserServiceImpl implements ISysUserSocialUserService {
    @Autowired
    private SysUserSocialUserMapper sysUserSocialUserMapper;


    /**
     * 根据条件分页查询关联系统账号数据
     *
     * @param sysUserSocialUser 过滤条件
     * @return 关联系统账号数据集合信息
     */
    @Transactional(readOnly = true)
    @Override
    public List<SysUserSocialUser> findSysUserSocialUserByCondition(SysUserSocialUser sysUserSocialUser) {

        return sysUserSocialUserMapper.findSysUserSocialUserByCondition(sysUserSocialUser);
    }


    /**
     * 查询关联系统账号
     *
     * @param id 关联系统账号ID
     * @return 关联系统账号
     */
    @Transactional(readOnly = true)
    @Override
    public SysUserSocialUser selectSysUserSocialUserById(String id) {
        return sysUserSocialUserMapper.selectById(id);
    }


    /**
     * 新增关联系统账号
     *
     * @param sysUserSocialUser 关联系统账号
     * @return 结果
     */
    @Transactional(readOnly = false, propagation = Propagation.REQUIRED, rollbackFor = Exception.class)
    @Override
    public int insertSysUserSocialUser(SysUserSocialUser sysUserSocialUser) {
        return sysUserSocialUserMapper.insert(sysUserSocialUser);
    }

    /**
     * 修改关联系统账号
     *
     * @param sysUserSocialUser 关联系统账号
     * @return 结果
     */
    @Transactional(readOnly = false, propagation = Propagation.REQUIRED, rollbackFor = Exception.class)
    @Override
    public int updateSysUserSocialUser(SysUserSocialUser sysUserSocialUser) {
        return sysUserSocialUserMapper.updateById(sysUserSocialUser);
    }

    /**
     * 批量删除关联系统账号
     *
     * @param ids 需要删除的关联系统账号ID
     * @return 结果
     */
    @Transactional(readOnly = false, propagation = Propagation.REQUIRED, rollbackFor = Exception.class)
    @Override
    public int deleteSysUserSocialUserByIds(String[] ids) {

        return sysUserSocialUserMapper.deleteBatchIds(Arrays.asList(ids));
    }

    /**
     * 删除关联系统账号信息
     *
     * @param id 关联系统账号ID
     * @return 结果
     */
    @Transactional(readOnly = false, propagation = Propagation.REQUIRED, rollbackFor = Exception.class)
    @Override
    public int deleteSysUserSocialUserById(String id) {
        return sysUserSocialUserMapper.deleteById(id);
    }

}
